﻿package mortal.game.view.palyer.renderer
{
    import com.mui.controls.*;
    import com.mui.utils.*;
    import flash.events.*;
    import flash.utils.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.view.common.item.*;
    import mortal.game.view.mount.panel.*;
    import mortal.game.view.palyer.util.*;
    import mortal.game.view.wizard.panel.*;

    public class FashionEquipCellRenderer extends GCellRenderer
    {
        private var _equipItem:OtherEquipItem;
        private var _equipData:ItemData;

        public function FashionEquipCellRenderer()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._equipItem = UICompomentPool.getUICompoment(OtherEquipItem);
            this._equipItem.setItemStyle(ItemStyleConst.Small, ImagesConst.EquipItemBg, 7, 7);
            this._equipItem.isDragAble = false;
            this._equipItem.buttonMode = true;
            this.addChild(this._equipItem);
            this.mouseEnabled = true;
            this.configEventListener(MouseEvent.DOUBLE_CLICK, this.onDBClickHandler);
            this.configEventListener(MouseEvent.CLICK, this.openSmallWin);
            return;
        }// end function

        override public function set data(param1:Object) : void
        {
            super.data = param1;
            this._equipData = param1 as ItemData;
            if (this._equipData && !this._equipData.extData)
            {
                this._equipItem.midLabel = "";
                this._equipItem.isShowLock = true;
                this._equipItem.isBind = this._equipData.bind == 0 ? (false) : (true);
                this._equipItem.bitmapEnable = true;
                this._equipItem.isShowColorBg = true;
                this._equipItem.isShowStreng = true;
            }
            else if (this._equipData && this._equipData.extData && this._equipData.extData.isDefault)
            {
                this._equipItem.midLabel = FashionUtil.getEquipName(this._equipData);
                this._equipItem.isShowLock = false;
                this._equipItem.bitmapEnable = false;
                this._equipItem.isShowColorBg = false;
                this._equipItem.isShowStreng = false;
            }
            this._equipItem.itemData = this._equipData;
            this._equipItem.updateStrengLevel(this._equipData.itemInfo.itemLevel);
            this._equipItem.isAutoUpdateEquip(true, this._equipData.itemInfo.group, this._equipData.itemInfo.category, this._equipData.itemInfo.type, FashionUtil.getPackPosTypeByEquip(this._equipData));
            return;
        }// end function

        private function onDBClickHandler(event:MouseEvent) : void
        {
            var _loc_2:int = 0;
            if (this._equipData && !this._equipData.extData)
            {
                _loc_2 = FashionUtil.getEquipFashionType(this._equipData);
                GameProxy.fashion.dress(_loc_2, null, this._equipData.uid);
            }
            return;
        }// end function

        private function openSmallWin(event:MouseEvent) : void
        {
            var _loc_2:* = event.currentTarget as OtherEquipItem;
            var _loc_3:* = this.getSmallWinTitleData();
            EquipBaseWin.instance.setWinData(_loc_3, FashionUtil.getPackPosTypeByEquip(this._equipData), this._equipData.itemInfo.group, this._equipData.itemInfo.category, this._equipData.itemInfo.type);
            EquipBaseWin.instance.show(GameController.playerSystem.view.x + 111, GameController.playerSystem.view.y + 190);
            return;
        }// end function

        private function getSmallWinTitleData() : Dictionary
        {
            var _loc_1:* = new Dictionary();
            var _loc_2:* = FashionUtil.getEquipName(this._equipData);
            _loc_1[this._equipData.itemInfo.type] = [{name:"equip", label:_loc_2}];
            return _loc_1;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl();
            this._equipItem.dispose();
            this._equipItem = null;
            this._equipData = null;
            if (EquipBaseWin.isViewShow)
            {
                EquipBaseWin.instance.hide();
            }
            return;
        }// end function

    }
}
